package com.hoperun.checkcloth.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.hadilq.liveevent.LiveEvent
import com.hoperun.checkcloth.entity.MaterialEntity
import com.hoperun.checkcloth.util.Logger

class StuffCheckInfoViewModel : ViewModel() {
    private val logger = Logger.create("StuffCheckViewModel")

    private var _selectedItem: MaterialEntity? = null
    private val selectedItem = MutableLiveData<MaterialEntity>()
    val getSelectItem: LiveData<MaterialEntity> = selectedItem

    private val _dialogMessage = LiveEvent<String>()
    val dialogMessage: LiveData<String> = _dialogMessage

    fun onConfirmButtonClicked() {
        logger.d("onConfirm $_selectedItem")
        _selectedItem?.let {
            selectedItem.value = it
            return
        }

        _dialogMessage.value = "请选择一条原料信息！"
    }

    fun onItemSelected(item: MaterialEntity?) {
        logger.d("onItemSelected $item")
        _selectedItem = item
    }
}